package robot;

import java.util.logging.Logger;

import com.google.wave.api.Blip;
import com.google.wave.api.ElementType;
import com.google.wave.api.Event;
import com.google.wave.api.FormElement;
import com.google.wave.api.TextView;

public class OperationFormController extends BaseFormController
{

	/**
	 * The caption of the add button.
	 */
	private static final String ADD_STATUS_BUTTON_CAPTION = "Add Status";

	/**
	 * The caption of the add button.
	 */
	private static final String GET_STATUS_BUTTON_CAPTION = "Get Status";

	private static final Logger log = Logger.getLogger(OperationFormController.class.getName());
	
	public OperationFormController(Blip blip)
	{
		super(blip);
	}

	@Override
	public void renderForm()
	{
		TextView document = blip.getDocument();

		// content of the root blip gets duplicated unless previous text is
		// deleted
		document.delete();
		document.append("\n\n");
		
		document.appendElement(new FormElement(ElementType.BUTTON,
				ADD_STATUS_BUTTON_ID, ADD_STATUS_BUTTON_CAPTION));
		
		document.appendElement(new FormElement(ElementType.BUTTON,
				GET_STATUS_BUTTON_ID, GET_STATUS_BUTTON_CAPTION));
		
	}
	
	/**
	 * Checks whether the add status button is clicked or not.
	 * 
	 * @return A {@code true} if the login button is clicked.
	 */
	public boolean isAddButtonClicked(Event event)
	{
		return ADD_STATUS_BUTTON_ID.equals(event.getButtonName());
	}

	/**
	 * Checks whether the add status button is clicked or not.
	 * 
	 * @return A {@code true} if the login button is clicked.
	 */
	public boolean isGetButtonClicked(Event event)
	{
		return GET_STATUS_BUTTON_ID.equals(event.getButtonName());
	}

}
